package com.daydayup.easypoi.model.dto;

import cn.afterturn.easypoi.excel.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.io.Serializable;
import java.util.List;

/**
 * 承载合计行<br>
 *
 * @author luo_zm
 * @create 2019/11/3 16:00
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ToString
public class BearerConstructionTotalDTO implements Serializable {

    private static final long serialVersionUID = -2366512819651753375L;

    @ApiModelProperty(value = "合计", example = "合计", position = 20)
    @Excel(name = "合计")
    private String unitName;

    @ApiModelProperty(value = "变电工程数量合计", example = "66", position = 30)
    @Excel(name = "变电工程数量合计")
    private Integer electricProjectAmountTotal = 0;

    @ApiModelProperty(value = "所有变电工程总容量合计", example = "66", position = 40)
    @Excel(name = "变电容量/万千伏安")
    private Double substationCapacityTotal = (double) 0;

    @ApiModelProperty(value = "线路工程数量合计", example = "66", position = 50)
    @Excel(name = "线路工程数量")
    private Integer lineProjectAmountTotal = 0;

    @ApiModelProperty(value = "线路长度合计", example = "66", position = 60)
    @Excel(name = "线路长度/公里")
    private Double lineLongerTotal = (double) 0;

    @ApiModelProperty(value = "变电工程可组建项目部数量合计", example = "66", position = 70)
    @Excel(name = "可组建项目部数量")
    private Integer eltProjectDepTotal = 0;

    @ApiModelProperty(value = "变电工程可组建项目部可调配数量合计", example = "66", position = 80)
    @Excel(name = "可调配/以饱和")
    private Integer eltProjectDepResidueTotal = 0;

    @ApiModelProperty(value = "变电工程可组建班组数量合计", example = "66", position = 90)
    @Excel(name = "可组建班组数")
    private Integer eltProjectGroupTotal = 0;

    @ApiModelProperty(value = "变电工程可组建班组可调配数量合计", example = "66", position = 90)
    @Excel(name = "可调配/以饱和")
    private Integer eltProjectGroupResidueTotal = 0;

    @ApiModelProperty(value = "线路工程可组建项目部数量合计", example = "66", position = 70)
    @Excel(name = "可组建项目部数量")
    private Integer lineProjectDepTotal = 0;

    @ApiModelProperty(value = "线路工程可组建项目部可调配数量", example = "66", position = 80)
    @Excel(name = "可调配/以饱和")
    private Integer lineProjectDepResidueTotal = 0;

    @ApiModelProperty(value = "线路工程可组建班组数量合计", example = "66", position = 90)
    @Excel(name = "可组建班组数")
    private Integer lineProjectGroupTotal = 0;

    @ApiModelProperty(value = "线路工程可组建班组可调配数量合计", example = "66", position = 90)
    @Excel(name = "可调配/以饱和")
    private Integer lineProjectGroupResidueTotal = 0;

    @ApiModelProperty(value = "注释", example = "66", position = 90)
    @Excel(name = "注释")
    private String notes;

    public BearerConstructionTotalDTO(List<BearerConstructionDTO> bearerConstructionDTOList) {

        bearerConstructionDTOList.stream().forEach(bearerConstructionDTO -> {
            this.electricProjectAmountTotal += bearerConstructionDTO.getElectricProjectAmount();
            this.substationCapacityTotal += bearerConstructionDTO.getSubstationCapacity();
            this.lineProjectAmountTotal += bearerConstructionDTO.getLineProjectAmount();
            this.lineLongerTotal += bearerConstructionDTO.getLineLonger();
            this.eltProjectDepTotal += bearerConstructionDTO.getEltProjectDep();
            this.eltProjectDepResidueTotal += bearerConstructionDTO.getEltProjectDepResidue();
            this.eltProjectGroupTotal += bearerConstructionDTO.getEltProjectGroup();
            this.eltProjectGroupResidueTotal += bearerConstructionDTO.getEltProjectGroupResidue();
            this.lineProjectDepTotal += bearerConstructionDTO.getLineProjectDep();
            this.lineProjectDepResidueTotal += bearerConstructionDTO.getLineProjectDepResidue();
            this.lineProjectGroupTotal += bearerConstructionDTO.getLineProjectGroup();
            this.lineProjectGroupResidueTotal += bearerConstructionDTO.getLineProjectGroupResidue();
        });
    }
}
